﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;

namespace Cabal.Kernel.Cryptilogy
{
    /// <summary>
    /// 默认非对称密钥加密
    /// </summary>
    public class CProviderRSA:ICryptProvider
    {
        public CProviderRSA(string publickey,string mod)
        {
            _rsa = new RSACrypt(null, publickey, mod);
        }

        RSACrypt _rsa;

        #region ICryptProvider 成员

        public string GetName()
        {
            return "default";
        }

        public byte[] DecryptData(byte[] c)
        {
            return _rsa.Decrypt(c);
        }

        public byte[] EncryptData(byte[] m)
        {
            return _rsa.Encrypt(m);
        }

        public string DecryptStringBase64(string c)
        {
            return _rsa.DecryptBase64String(c);
        }

        public string EncryptStringBase64(string m)
        {
            return _rsa.EncryptBase64String(m);
        }

        #endregion
    }

}
